#ifndef EXPRESSIONTREE_H_
#define EXPRESSIONTREE_H_

#include<string>
#include<stack>
using namespace std;


class expressionTree {

public:
	expressionTree(const string &postfix);
	expressionTree(bool isOperator, char data, expressionTree* Ltree = nullptr, expressionTree* rtree = nullptr);
	expressionTree(bool isOperator, double data, expressionTree* Ltree = nullptr, expressionTree* rtree = nullptr);
	
	void destruct();
	~expressionTree();

	bool isOperator();
	void setDataType(bool isOperators);
	void setData(const string &data);
	void setLTree(expressionTree *ltree);
	void setRTree(expressionTree *rtree);
	

	string getData();
	expressionTree *getLTree();
	expressionTree *getRTree();

	bool visit(string &expression);
	string getPrefixExpression();
	bool getInfixExpression(string &infixExpression);
	string getPostfixExpression();

private:
	char putExpressionIntoStack(istringstream &in, stack<expressionTree*> &trees);
	void compoundNewTree(char operators, stack<expressionTree*> &trees);
	const string modify(string &doublestr);
private:

	bool isOperators;
	union {
		char operators;
		double operand;
	};
	expressionTree *LTree;
	expressionTree *RTree;
};


#endif